(function() {
    angular.module('BlurAdmin.pages.redAdminM')
        .controller('redDetailsCtrl', redDetailsCtrl);

    function redDetailsCtrl($scope, $address, $ShareData) {
        console.log($ShareData.getRed());

        var red_opt = $scope.red_opt = $ShareData.getRed();

        //饼状图数据
        $scope.tpo = 1;
        $scope.myTabs = function(val) {
            $scope.tpo = val;
        }
        var pageload = {
            name: '金额',
            datapoints: [
                { x: '已发放红包金额', y: (red_opt.amount - red_opt.remainedamount) / 100 },
                { x: '剩余红包金额', y: red_opt.remainedamount / 100 }
            ]
        };

        $scope.jbg_config = {
            title: {
                text: '剩余红包金额/已发放红包金额',
                x: 'center'
            },


            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} "
            },

            legend: {
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c}"
                },
                orient: 'horizontal',
                y: 'bottom',
                padding: '20',
                data: ['已发放红包金额', '剩余红包金额']
            },
            series: [{
                name: '红包金额',
                type: 'pie',
                radius: '55%',
                center: ['50%', '60%'],
                data: [
                    { value: (red_opt.amount - red_opt.remainedamount) / 100, name: '已发放红包金额' },
                    { value: red_opt.remainedamount / 100, name: '剩余红包金额' }
                ]
            }]
        };


        $scope.data = [pageload];
        $scope.data2 = [{
            name: '个数',
            datapoints: [
                { x: '已领取红包', y: red_opt.number - red_opt.leavings },
                { x: '剩余红包', y: red_opt.leavings }
            ]
        }];
        $scope.jbg_config2 = {
            title: {
                text: '已领取红包/剩余红包',
                x: 'center'
            },


            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} "
            },

            legend: {
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} "
                },
                orient: 'horizontal',
                y: 'bottom',
                padding: '20',
                data: ['已领取红包', '剩余红包']
            },
            series: [{
                name: '红包个数',
                type: 'pie',
                radius: '55%',
                center: ['50%', '60%'],
                data: [
                    { value: red_opt.number - red_opt.leavings, name: '已领取红包' },
                    { value: red_opt.leavings, name: '剩余红包' }
                ]
            }]
        };



    }
})();